package com.sctvcloud.weiyuan.ui.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.weiyuan.R;
import com.sctvcloud.weiyuan.beans.FRebellion;
import com.sctvcloud.weiyuan.beans.GovDetailBean;
import com.sctvcloud.weiyuan.beans.NewsItem;
import com.sctvcloud.weiyuan.ui.adapter.holder.ApplyHolder;
import com.sctvcloud.weiyuan.ui.adapter.holder.BaseRebllionHolder;
import com.sctvcloud.weiyuan.ui.adapter.holder.GovDetailHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/6/26 0026.
 */

public class GovAdapter extends BaseHolderAbsAdapter<NewsItem, GovDetailHolder> implements OnItemInternalClick {
    private OnItemInternalClick onItemInternalClick;
    private Activity activity;

    public GovAdapter(Context context,List<NewsItem> list) {
        super(context, list);
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    @Override
    public GovDetailHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        GovDetailHolder govHolder;
        LayoutInflater inflater = LayoutInflater.from(context);
        govHolder = new GovDetailHolder(context, inflater.inflate(R.layout.item_gov_detail, parent, false));
        govHolder.setInternalClick(this);
        govHolder.setActivity(activity);
        return govHolder;
    }

    @Override
    public int getItemViewType(int position) {
        return data.get(position).getDataType();
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        if (onItemInternalClick != null) {
            onItemInternalClick.onItemInternalClick(itemView, view, position);
        }
    }

    @Override
    public GovAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        this.onItemInternalClick = itemInternalClick;
        return this;
    }

}
